import { reactive } from 'vue'
import { defineStore } from 'pinia'

export interface IUserProps {
  isLogin: boolean;
  userName?: string;
}

export interface IUserStore {
  user: IUserProps;
  login: (name?:string) => void;
  logout: () => void;
}

export const useUserStore = defineStore('counter', ():IUserStore => {
  const user = reactive({
    isLogin: false,
    userName: 'devin'
  })
  const login = (name?:string) => {
    user.isLogin = true
    user.userName = name || 'devin'
  }
  const logout = () => {
    user.isLogin = false
  }
  return { user, login, logout }
})
